package com.hp.bon.sgw.threads;

import com.hp.bon.sgw.core.CallParam;
import com.hp.bon.sgw.service.BlackListSgwViewService;
import com.hp.ocs.diameter.message.dictionary.AvpType;

import java.util.LinkedList;

public class TaskManager
{
	/**
	 * 在开始处理业务之前，启动任务线程
	 */
	static public void startThreads()
	{
		BusinessRecordCacheManager.getInstance().start();
		MessageDetailCacheManager.getInstance().start();
		StateAnalysThread.getInstance().start();
		StateMonitorThread.getInstance().start();
		Top100CacheManager.getInstance().start();
		BlacklistMonitorThread.getInstance().start();
		
		
	}
	/**
	 * 业务停止处理后，再停止任务线程，然后等待waitMs后进程再完全退出
	 * @param waitMs
	 */
	public static void stopThreads(long waitMs) {
		BusinessRecordCacheManager.getInstance().exit();
		MessageDetailCacheManager.getInstance().exit();		
		StateAnalysThread.getInstance().exit();		
		StateMonitorThread.getInstance().exit();
		Top100CacheManager.getInstance().exit();
		BlacklistMonitorThread.getInstance().exit();
		
		try
		{
			Thread.sleep(waitMs);
		} catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}
	static String express = "/Service_Information/Balance_Information/Destination_Id";
	static public void taskProcess(CallParam callParam)
	{
	    if(callParam != null ){
            BusinessRecordCacheManager.getInstance().add(callParam);
            StateAnalysThread.getInstance().updateStat4SCIDMap(callParam);
            //TODO Top100处理
            Top100CacheManager.getInstance();
            //业务黑名单
            BlacklistMonitorThread.getInstance().add(callParam);
            //业务黑名单：能力视图  add by wanghan
            BlackListSgwViewService.getInstance().checkAddBlackList(callParam);

//		FluxControlByRcService.getInstance().countFluxAfterSGWSend(callParam);
        }
        // 消息详单入库,日志入库
        MessageDetailCacheManager.getInstance();
			
	}

	static LinkedList<String> xmlPath= new LinkedList<String>();
	static LinkedList<AvpType> avpPath = new LinkedList<AvpType>();
	
	
}
